//
//  Test8.cpp
//  CPPTest
//
//  Created by you5 Yi on 2021/9/13.
//

#include "Test8.hpp"
#include <iostream>
class base {
private:int x;
public:base(int a){x=a;}
    int get() {return x;}
    void showbase() {
        std::cout<<"x="<<x<<std::endl;
    }
};

class Derived: public base {
private:int y;
public: Derived(int a,int b): base(a){y=b;}
    void showderived() {
        std::cout<<"x="<<get()<<",y="<<y<<std::endl;
    }
};

void test8() {
    base b(3);
    Derived d(6,7);
    b.showbase();//x=3;
    d.showderived();//x=6,y=7;
    b = d;
    b.showbase();//x=6;
    base &b1 = b;
    b1.showbase();//x=6;
    base *pb = &b1;
    pb -> showbase();//x=6;
    d.showderived();//x=6,y=7;
    b.showbase();//x=6;
}
